home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / WINLIST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  2.0 KB  |  90 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // FusionWindow
  8. //
  9.  
  10. #include "fliwin.h"
  11. #include "elements.h"
  12.  
  13. #ifdef __BCPLUSPLUS__
  14. #pragma hdrstop
  15. #endif
  16.  
  17. #include <alloc.h>
  18.  
  19. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  20. //
  21. // ListAndSelect()
  22. //
  23. // List and select from the current array of windows
  24. //
  25. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  26.  
  27. const winAcceptButton=32765;
  28. const winCancelButton=32766;
  29.  
  30. class ListDialog : public DialogClass
  31. {
  32. public:
  33.  
  34.   ListDialog(int Width,int Height) :
  35.     DialogClass(Width,Height,"Window Select") { }
  36.  
  37.   int EventHandler(int Event)
  38.   {
  39.     if (Event==kbEsc ||
  40.         Event==kbCr ||
  41.         Event==CloseEvent ||
  42.         Event==OutsideEvent ||
  43.         Event==winAcceptButton ||
  44.         Event==winCancelButton)
  45.       return StopEvent;
  46.     return CompleteEvent;
  47.   }
  48. };
  49.  
  50. void FusionWindow::ListAndSelect()
  51. {
  52.   if (!NumberOfWindows)
  53.     return;
  54.  
  55.   char **Titles=(char**)malloc(NumberOfWindows*sizeof(char*));
  56.  
  57.   for (int i=0;i<NumberOfWindows;i++)
  58.     Titles[i]=Windows[i]->Title;
  59.  
  60.   ListDialog &Dialog=*new ListDialog(60,15);
  61.  
  62.   int WindowToSelect=0;
  63.  
  64.   Dialog.Element(new DiaPickList(1,2,53,8,WindowToSelect,NumberOfWindows,Titles));
  65.   Dialog.FusionHelp(32767);
  66.   Dialog.HotKey(1,1,"~Select a Window",kbAltS);
  67.   Dialog.Help("These are the windows");
  68.  
  69.   Dialog.Element(new DiaPushButton(8,11,"~Choose This Window",winAcceptButton,kbAltC));
  70.   Dialog.Help("Choose the highlighted and jump to it");
  71.  
  72.   Dialog.Element(new DiaPushButton(36,11,"Stay ~Here",winCancelButton,kbAltH));
  73.   Dialog.Help("Cancel and return to the menu, without selecting a window");
  74.  
  75.   int Value=Dialog.UseDialog();
  76.  
  77.   delete &Dialog;
  78.   free(Titles);
  79.  
  80.   if (Value==kbEsc || Value==OutsideEvent || Value==CloseEvent || Value==winCancelButton)
  81.     return;
  82.   else
  83.   {
  84.     RemoveAllMenus();
  85.     if (WindowToSelect)
  86.       CallWindow(WindowToSelect);
  87.   }
  88. }
  89.  
  90.